home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 6
/
CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso
/
cucd
/
readers
/
utils
/
gui4cli
/
demos
/
cli.gc
< prev
next >
Wrap
Text File
|
1996-10-28
|
4KB
|
157 lines
G4C - 24/2/96 dck - GUI for Commands
; This GUI is similar to the Workbench "Execute command" GUI, but more.
; There is a textin gadget for entering commands, buttons for choosing
; files, changing the directory, and opening a newshell.
; More important, it can also send ARexx commands to the port shown
; in the other (bottom right) textin gadget (which can also be changed)
; On clicking the right mouse button an other GUI named "keyboard.g"
; is opened - It provides a letter pad to write commands using the
; mouse - not very useful, but pretty :)
; Don't let the subroutine for this confuse you...
; It's nothing important and you will not need it in your own GUIs.
WinBig 10 30 520 38 "Enter commands :"
WinSmall 0 -1 422 30
WinType 11110010
; On loading, we set the default values of the variables & open window
xOnLoad
ifexists variable gcMain ; if a commandline has previously been set
; ; don't clear it
else
setvar gcMain "" ; Else, set & clear it.
endif
setvar gcMode G4C ; Mode to run the command
setvar gcPort Gui4Cli ; Name of default port (can also sendrexx to ourselves)
setvar kbdGadID 1 ; ID of TEXTIN gadget to edit with the keyboard.g GUI
; On opening we display the current directory in the titlebar (note large buffer)
xOnOpen
setwintitle cli.gc "$$CURRENT_DIR "
Update cli.gc 1 $gcMain ; show whatever the command line is
SetGad cli.gc 1 ON ; to get the cursor in the gadget immediately
; On quitting we delete the variables
xOnQuit
delvar gcMain
delvar gcMode
delvar gcPort
delvar gcEdit
;--------------------- On Right Mouse Button we open the keyboard.g GUI
; We must set 3 variables before opening it - read the GUI to understand
xOnRMB
setvar kbdGui cli.gc
if $kbdGadID < " " ; if 1st time
setvar kbdGadID 1 ; set gad to 1
endif
if $kbdGadID = 1
setvar kbdBuffer gcMain ; set kbdBuffer according to gadID
else
setvar kbdBuffer gcEdit
endif
GuiLoad GUIs:demos/keyboard.g
GuiOpen keyboard.g
;-------- 2 Radio buttons to let us choose the edit target
xRADIO 494 6 17 9 kbdGadID 9
RSTR "" 1
RSTR "" 2
if $kbdGadID = 1
setvar kbdBuffer gcMain
setgad cli.gc 1 ON
else
setvar kbdBuffer gcEdit
setgad cli.gc 2 ON
endif
;================================> Main text input gadget
xTEXTIN 10 3 480 16 "" gcMain "" 512
gadid 1
gosub cli.gc DoCommand
;========> Cycler for choosing ARexx/CLI/RUN modes
xCYCLER 10 20 80 14 "" gcMode
GadID 10 ; we may want to change it from elsewhere
CSTR ARexx G4C
CSTR CLI CLI
CSTR RUN RUN
;========> GO button (to execute the command)
xBUTTON 90 20 40 14 "GO!"
gosub cli.gc DoCommand
;========> Button for File requester for filenames (or commands)
xBUTTON 135 20 65 14 "Files.."
setvar gcFile ""
REQFILE -1 -1 300 -60 "Choose Files" MULTI gcFile $$CURRENT_DIR
if $gcFile > ""
appvar gcMain $gcFile
update cli.gc 1 $gcMain
endif
;========> Button to open a shell
xBUTTON 200 20 60 14 Shell
CLI 'Newshell "con:0/150/640/100/NewShell/CLOSE"'
;========> Button to change directory
xBUTTON 260 20 60 14 CD
setvar gcDir ""
REQFILE -1 -1 300 -60 "Choose directory" DIR gcDir ""
if $gcDir > ""
CD $gcDir
SetWinTitle cli.gc "$gcDir "
endif
;========> TEXTin gadget to get port name for sendrexx command
xTEXTIN 370 20 120 16 "Port" gcPort "Gui4Cli" 40
GadID 2
;========> ROUTINE to execute command
xROUTINE DoCommand
docase $gcMode
case = G4C
SendRexx $gcPort $gcMain
SetWinTitle cli.gc "Rexx returned : $$RETCODE $$REXXRET "
break
case = CLI
CLI $gcMain
SetWinTitle cli.gc "CLI Returned : $$RETCODE"
break
case = RUN
RUN $gcMain
SetWinTitle cli.gc "RUN Returned : $$RETCODE"
break
endcase
;=========> before commands are executed, we restore the window title
xBEFORE
SetWinTitle cli.gc "$$CURRENT_DIR "